<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function muti(num){
            return new Promise((resolve,reject)=>{
                setTimeout(() => {
                    resolve(num*num)
                }, 1000);
            })
        }
        /* of支持异步循环 */
        /* forEach是一个同步的循环 */
        var arr = [2,3,4];
        /* (async ()=>{
            arr.forEach(async(item)=>{
                var res = await muti(item);
                console.log(res);
            })
        })(); */
        (async ()=>{
            for(let value in arr){
                let res = await muti(value);
                console.log(res);
            }
        })();
    </script>
</body>
</html>